# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=cloudsploit
pkgver=6684.4b5bbd809
pkgrel=1
pkgdesc='AWS security scanning checks.'
arch=('any')
groups=('blackarch' 'blackarch-scanner' 'blackarch-automation')
url='https://github.com/cloudsploit/scans'
license=('GPL3')
depends=('nodejs')
makedepends=('git' 'npm')
source=("$pkgname::git+https://github.com/$pkgname/scans.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  npm install

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec node index.js "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

